/**
 * API配置文件
 * 定义所有API端点和基础配置
 */

// API基础URL - 从环境变量读取，默认使用本地开发地址
export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000/api'

/**
 * API端点配置
 */
export const API_ENDPOINTS = {
  // ==================== 认证相关 ====================
  AUTH_REGISTER: '/auth/register',
  AUTH_LOGIN: '/auth/login',
  AUTH_SEND_CODE: '/auth/send-code',
  AUTH_EMAIL_LOGIN: '/auth/email-login',
  AUTH_RESET_PASSWORD: '/auth/reset-password',
  AUTH_LOGOUT: '/auth/logout',
  AUTH_ME: '/auth/me',
  AUTH_REFRESH: '/auth/refresh',
  
  // ==================== 用户管理 ====================
  USER_LIST: '/users/',
  USER_PROFILE: (id) => `/users/${id}`,
  USER_UPDATE: (id) => `/users/${id}/update`,
  USER_UPDATE_PROFILE: '/auth/profile/',  // 当前用户资料更新接口（支持文件上传）
  USER_CHANGE_PASSWORD: (id) => `/users/${id}/change-password`,
  USER_STATS: (id) => `/users/${id}/stats`,
  
  // ==================== 故事管理 ====================
  STORY_GENERATE: '/stories/generate',
  STORY_LIST: '/stories/',
  STORY_DETAIL: (id) => `/stories/${id}`,
  STORY_CREATE: '/stories/create',
  STORY_UPDATE: (id) => `/stories/${id}/update`,
  STORY_PUBLISH: (id) => `/stories/${id}/publish`,
  STORY_DELETE: (id) => `/stories/${id}/delete`,
  STORY_APPROVE: (id) => `/stories/${id}/approve`,
  STORY_REJECT: (id) => `/stories/${id}/reject`,
  STORY_TOP: '/stories/top',
  STORY_CATEGORIES: '/stories/categories',
  STORY_USER: (id) => `/stories/user/${id}`,
  
  // ==================== 社交互动 ====================
  STORY_LIKE: (id) => `/stories/${id}/like`,
  STORY_BOOKMARK: (id) => `/stories/${id}/bookmark`,
  STORY_COMMENTS: (id) => `/stories/${id}/comments`,
  COMMENT_ADD: (id) => `/stories/${id}/comments/add`,
  COMMENT_DELETE: (storyId, commentId) => `/stories/${storyId}/comments/${commentId}`,
  COMMENT_LIKE: (storyId, commentId) => `/stories/${storyId}/comments/${commentId}/like`,
}

/**
 * 请求超时配置（毫秒）
 */
export const REQUEST_TIMEOUT = 30000 // 30秒

/**
 * 故事分类列表
 */
export const STORY_CATEGORIES = [
  '奇幻', '科幻', '冒险', '爱情', '悬疑', 
  '恐怖', '历史', '现代', '武侠', '仙侠'
]

/**
 * 用户角色
 */
export const USER_ROLES = {
  USER: 'user',
  CREATOR: 'creator',
  ADMIN: 'admin'
}

/**
 * 故事状态
 */
export const STORY_STATUS = {
  DRAFT: 'draft',
  PUBLISHED: 'published'
}
